<%@page language="java" contentType="text/html; charset=UTF-8" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="html" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>
<html>
<html:header title="序列号跟踪">
<%--入库和出库这两种情况--%>
    <link rel="stylesheet" href="${baseUrl}css/public.css" media="all">

    <style type="text/css">
        a{
            color: #01AAED;
            text-decoration: none;
            font-size: 12px;
        }
        a:hover {
            color: #FF5722;
        }

        label{
            display:-moz-inline-box;
            display:inline-block;
            width:80px;
            color: #aaaaaa;
        }

        .info{
            padding: 2px;
        }
    </style>

    <script>
        jQuery(function () {
            $("#cancel").click(function () {
                closeSubIframe(window.location.href);
            });
        });

        layui.use(['form', 'table', 'laydate'], function () {
            let $ = layui.jquery,
                form = layui.form,
                table = layui.table,
                laydate = layui.laydate,
                util = layui.util;


            get("${baseUrl}house/goodsSn/getVoById.action?id=${id}", function (res) {
                if (res.code == 1) {
                    let goodsSnVo = res.data;
                    $("#name").html(goodsSnVo.goodsVo.name);
                    $("#sn").html(goodsSnVo.sn);
                    $("#remark").html(goodsSnVo.remark);

                    $("#goodsImg").attr("src", "${baseUrl}img/goods/"+goodsSnVo.goodsVo.image);

                    if (goodsSnVo.status == 1) {
                        $("#status").html("-在库");
                    } else {
                        $("#status").html("-已出库");
                    }

                    renderTable(goodsSnVo);
                }else {
                    tip("获取序列号信息失败");
                }
            });
        });

        function renderTable(goodsSnVo) {
            layui.table.render({
                id: 'table',
                elem: '#table',
                url: "${baseUrl}house/goodsSnLog/getList.action",
                where : {
                    goodsId:goodsSnVo.goodsId,
                    sn:goodsSnVo.sn,
                    time:(new Date()).valueOf()
                },
                text: {
                    none: '无'
                },
                cols: [[
                    {width:70,title:"序号",templet:function (d) {
                        return genTableIndex(d.close,"作废", d);
                    }},
                    {field:'date',width: 140, title: '业务日期',templet: function (d) {
                        return GMTToDate(d.date);
                    }},
                    {field:'typeName',width: 140, title: '业务类型',style:"font-size:12px;"},
                    {field:'linkNo',width: 140, title: '关联单号',templet: '#linkNoBar'},
                    {field:'oper',width: 140, title: '操作',style:"font-size:12px;"},
                    {width: 140, title: '操作日期',style:"font-size:12px;", templet: function (d) {
                        return GMTToDate(d.time);
                    }},
                    {field:'storeName',width: 140, title: '门店',style:"font-size:12px;"},
                    {field:'houseName',width: 140, title: '仓库',style:"font-size:12px;"},
                ]],
                limit: 10,
                page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                    layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                    //,curr: 5 //设定初始在第 5 页
                    ,groups: 5 //只显示 5 个连续页码
                    ,first: false //不显示首页
                    ,last: false //不显示尾页
                },
                done: function (res, curr, count) {

                    $(".linkNo").click(function () {
                        openTab($(this).attr("linkTitle"),$(this).attr("linkUrl"));
                    });
                    setTableLineCss("table",res.data, "close", true, "font-gray-c2c2c2");
                }
            });
        }
    </script>

</html:header>

<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <div style="overflow:hidden; padding: 10px 0px">
            <div style="float: left">
                <img id="goodsImg" src="" alt="" style="background-color:#eeeeee;border: 4px solid #eeeeee; border-radius: 4px;width: 97px;height: 97px;"
                     onerror="this.src='${baseUrl}images/noImg.jpg'">
            </div>

            <div style="float: left;padding-left: 20px;">
                <div>
                    <span style="font-size: 20px;font-weight: bold;" id="name"></span>
                    <span id="status"></span>
                </div>
                <div class="info"><label>序列号:</label><span id="sn"></span></div>
                <div class="info"><label>备  注:</label><span id="remark"></span></div>
            </div>
        </div>

        <div style="clear: both;"></div>
        <hr>

        <table class="layui-hide" id="table" lay-filter="table" lay-size="sm"></table>
    </div>
</div>

</body>

<script type="text/html" id="linkNoBar">
    {{#  if((_login_user.viewOtherOrder && _login_user.store.sys) || _login_user.id==d.userId){ }}
    <a class="linkNo" href="javascript:;" linkUrl="${baseUrl}{{d.url}}.action?id={{d.id}}" linkTitle="{{d.typeName}}详情" >{{d.no}}</a>
    {{# }else{ }}
    {{d.no}}
    {{# } }}
</script>

<html:loading/>
</html>